<template>
  <div id="app"  style="background-color: #c1ede2">
    <router-view/>
  </div>
</template>

<script>
  import router from "./router/index";
  import generateRoutes from "./router/parse";
  export default {
    name: "App",
    // 在SPA初始化时，立刻从本地存储中拿到原始数据，解析后注入到路由实例中【吐血】
    created() {
      if(!localStorage.menu){
        const menu = [
          {
            title:'图像处理', icon: 'el-icon-menu', children: [
              { path:'/feature-extract',title:'特征提取', icon: 'el-icon-setting' }
            ]
          },
          {
            title:'特征预提取', icon: 'el-icon-menu', children: [
              { path:'/roi',title:'ROI展示', icon: 'el-icon-setting' }
            ]
          },
          {
            title:'分类', icon: 'el-icon-menu', children: [
              { path:'/classify',title:'分类器选择', icon: 'el-icon-setting' }
            ]
          }
        ]
        localStorage.menu = JSON.stringify(menu);
      }
      if (localStorage.menu) {
        const menu = JSON.parse(localStorage.menu);
        const _routes = generateRoutes(menu);
        router.addRoutes(_routes);
      }
    }
  };
</script>

<style lang="scss">
  // 这里是坑啊，文件路径中好像不能用@符号
  // 引入全局样式
  @import './assets/scss/global.scss';
</style>
